package com.cai.xiaobai.result;

/**
 * 响应结果生成工具
 */

public class R {
    // 只返回状态
    public static Result Success(ResultCode resultCode, String message) {
        return new Result().setCode(resultCode).setMessage(message).setSuccess(true);
    }

    // 成功返回数据
    public static Result Success(ResultCode resultCode, String message, Object data) {
        return new Result()
            .setCode(resultCode)
            .setMessage(message)
            .setData(data)
            .setSuccess(true);
    }

    // 失败
    public static Result Fail(ResultCode resultCode, String message) {
        return new Result()
            .setCode(resultCode)
            .setMessage(message)
            .setSuccess(false);
    }

    // 失败
    public static Result Fail(int resultCode, String message) {
        return new Result()
            .setCode(resultCode)
            .setMessage(message)
            .setSuccess(false);
    }

    public static Result Success(Object data) {
        return new Result()
            .setCode(ResultCode.SUCCESS)
            .setData(data)
            .setSuccess(true);
    }
}